Tag Systems States Graph
Tag Systems States Graph
In[]:=
<< GeneralUtilities`;
In[]:=
postRules = { (* {phase, value} {newPhase, newValues} *) {0, 0} {1, {0}}, {1, 0} {2, {0}}, {2, 0} {0, {}}, {0, 1} {2, {1, 1}}, {1, 1} {0, {1}}, {2, 1} {1, {0}}};
In[]:=
PostTagSystemNext[state : PostState[_, {}]] := {}
In[]:=
PostTagSystemNext[PostState[phase_, state_]] := ModuleScope[ {newPhase, newTokens} = Replace[postRules][{phase, First[state]}]; PostState[newPhase, Join[Rest[state], newTokens]]]
In[]:=
AllInits[count_] := PostState @@@ Tuples[{Range[0, 2], IntegerDigits[#, 2, count] & /@ Range[0, 2^count - 1]}]
In[]:=
AllInits[min_ ;; max_] := Catenate[AllInits /@ Range[min, max]]
In[]:=
?NestWhile
Out[]=
NestWhile[]
In[]:=
NestGraph[PostTagSystemNext,{PostState[0,{0,0,0}],PostState[1,{1,1,1}]},1000,VertexLabels(PostState[phase_,state_]Replace[phase,{0"0",1"1",2"2"}]<>StringJoin[Replace[state,{0"",1"■"},1]]),VertexStyle{PostState[phase_,state_/;Length[state]>sizeLimit]Directive[Red,Large]}(*VertexSize{PostState[phase_,state_/;(Length[state]>sizeLimit||Length[state]0)]1.5}*)]
Out[]=
WolframModel[<|"PatternRules"{{left_,h0},{h0,right_},{right_,0},{right_,farRight_}}Module[{newLeft},{{left,newLeft},{newLeft,0},{newLeft,h1},{h1,farRight}}]|>]
In[]:=
With[{sizeLimit=10},NestGraph[PostTagSystemNext,AllInits[0;;sizeLimit],1,VertexLabelsNone,VertexLabels(PostState[phase_,state_]Replace[phase,{0"0",1"1",2"2"}]<>StringJoin[Replace[state,{0"",1"■"},1]]),VertexStyle{PostState[phase_,state_/;Length[state]>sizeLimit]Directive[Red,Large]}(*VertexSize{PostState[phase_,state_/;(Length[state]>sizeLimit||Length[state]0)]1.5}*)]]
Out[]=
In[]:=
With[{sizeLimit=∞},NestGraph[PostTagSystemNext,PostState[0,Append[ConstantArray[0,12],1]],10000,VertexLabels(PostState[phase_,state_]Placed[Replace[phase,{0"0",1"1",2"2"}]<>StringJoin[Replace[state,{0"",1"■"},1]],Tooltip]),VertexStyle{PostState[phase_,state_/;Length[state]>sizeLimit]Directive[Red,Large]}(*VertexSize{PostState[phase_,state_/;(Length[state]>sizeLimit||Length[state]0)]1.5}*)]]
Out[]=